package com.glsc.ngateway.common.api.flowable.dto;

import cn.hutool.core.annotation.Alias;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import java.time.LocalDate;
import java.time.LocalDateTime;

@JsonInclude
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class EventExportDto {
    @Alias(value = "事件标题")
    @ApiModelProperty(value = "事件标题")
    public String eventTitle;

    @Alias(value = "事件分级")
    @ApiModelProperty(value = "事件分级")
    private String eventGrade;

    /**
     * 多条则合并为一个字符串，换行
     */
    @Alias(value = "整改措施")
    @ApiModelProperty(value = "整改措施")
    private String detailImproves;

    @Alias(value = "事件系统")
    @ApiModelProperty(value = "事件系统")
    private String systemName;

    @Alias(value = "事件成因")
    @ApiModelProperty(value = "事件成因")
    private String eventCause;

    @Alias(value = "事件分类")
    @ApiModelProperty(value = "事件分类")
    private String eventClass;

    @Alias(value = "事件发生日期")
    @ApiModelProperty(value = "事件发生日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate eventHappenTime;

    @Alias(value = "发起人姓名")
    @ApiModelProperty(value = "发起人姓名")
    @Column(name = "flow_create_operator_name", columnDefinition = "varchar(30) comment '发起人姓名'")
    private String flowCreateOperatorName;

    @Alias(value = "流程创建时间")
    @ApiModelProperty(value = "流程创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime processCreateTime;
}
